import { Plugin, Context } from '@nuxt/types'

const routerPlugin: Plugin = (context: Context) => {
  const { app } = context
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  app.router!.beforeEach((to, from, next) => {
    context.store.commit('app/SET_LOADING', true)
    next()
  })
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  app.router!.afterEach((to, from) => {
    context.store.commit('app/SET_LOADING', false)
  })
}

export default routerPlugin
